#pragma once

#ifndef __LIT__CACHE__MANAGER__INCLUDED__HH__
#define __LIT__CACHE__MANAGER__INCLUDED__HH__

#include <LitCoreComponent.h>
#include <LitPrerequisites.h>
#ifndef LIT_STANDALONE
#include <OgreImage.h>
#endif
#include <LitStream.h>

namespace Lit
{
	class LIT_API CacheManager : public CoreComponent
	{
		String mBasePath;
	public:
	
		CacheManager();
		~CacheManager();
		
		Type type() const{ return COM_CACHEMANAGER;	} 

		bool isFileCached( const String &name, CacheLocation loc, const String &subdir = "" ) const;
		#ifndef LIT_STANDALONE
		Ogre::Image getCachedImage( const String &name, CacheLocation loc, const String &subdir = "" ) const;
		#endif
		FilePath getCachePath( const String &name, CacheLocation loc, const String &subdir ) const;
		FilePath getLocationPath( CacheLocation loc, const String &subdir = "" ) const;
		
		RefPtr<FileStream> openCachedResource( const String &name, bool binary, CacheLocation loc, const String &subdir = "" ) const;
		RefPtr<FileStream> createCachedResource( const String &name, bool binary, CacheLocation loc, const String &subdir = "" ) const;
		
#ifdef LIT_OGRE_SUPPORT
		virtual void initialise( const OgreDetails &details );
#else
		virtual void initialise( );
#endif
		virtual void shutdown();
	};
};

#endif